package com.mmcro.oauth.mapper;

import com.mmcro.oauth.entity.SysAuthority;
import com.mmcro.oauth.entity.SysUser;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserMapper {

    @Select("select * from sys_user where username = #{value}")
    SysUser findUserByName(String username);

    @Select("select * from sys_user where username = #{value}")
    SysUser findUserByMobile(String mobile);

    @Select(" select r.id,r.role_code as authority , r.role_name as name,r.role_description as `desc`  from sys_role r " +
            " JOIN  sys_user_role ur on  ur.role_id = r.id  " +
            " WHERE ur.user_id=#{value} ")
    List<SysAuthority> getAtuoritiesByUserId(int userId);

}
